/**
 * Project Name:HomeActivity
 * Date:2016-3-23上午11:22:36
 * Copyright (c) 2016, askzhao All Rights Reserved.
 *
 */
package com.kkd.kkdapp.Notify;

import java.util.Vector;

import android.os.Handler;
import android.os.Message;

/**
 * ClassName: NotifyHandler <br/>
 * date: 2016-3-23 上午11:22:36 <br/>
 *
 * @author askzhao
 * @version 
 */
public class NotifyHandler {

	/** 关注该通知的对象 */
	private Vector<Handler> mVecHandler = new Vector<Handler>();

	public void registerObserver(Handler handler) {
		mVecHandler.add(handler);
	}

	public void unRegisterObserver(Handler handler) {
		mVecHandler.remove(handler);
	}

	/**
	 * 发送通知界面
	 * 
	 * @param obj
	 */
	public void sendNotify(Object obj,int flag) {
		for (int i = 0; i < mVecHandler.size(); i++) {
			Message message = Message.obtain();
			message.what = flag;
			message.obj = obj;
			mVecHandler.get(i).sendMessage(message);
		}
	}

	public boolean isEmpty() {
		if (mVecHandler.size() == 0) {
			return true;
		}
		return false;
	}
}
